package metamodels;

import java.util.HashSet;
import java.util.Set;


public class Enumeration extends Classifier {

	Identifier identifier;
	IdentifiersSemicolon identifiers;
	
	public Enumeration(Identifier identifier, IdentifiersSemicolon identifiersSemicolon) {
		this.identifier = identifier;
		this.identifiers = identifiersSemicolon;
	}

	@Override
	public String toString() {
		return "enumeration " + identifier + " { " + identifiers + " } ";
	}
	
	@Override
	public Set<? extends String> getIdentifiers() {
		
		Set<String> ids = new HashSet<String>();
		
		ids.add(identifier.toString());
		
		for (Identifier i : identifiers.identifiers)
			ids.add(i.toString());
		
		return ids;
	}
	
	@Override
	public String getName() {
		return identifier.toString();
	}
	
	@Override
	public Identifier getIdentifier() {
		return identifier;
	}

	public String getEnumRules() {
		
		String out = "rule isEnum(" + getName() + ") => true [:structural:]\n";
		out += "rule isEnum(Id:#Id) => false if notBool(Id ==Bool " + getName() + ")  [:structural:]";
		
		return out;
	}

	public String getEnumValuesRule() {
		String out = "";
		
		for (Identifier i : identifiers.identifiers)
			out += "BagItem(" + i.toString() + ")\n";
		
		return "rule values(" + identifier.toString() + ") => .Bag\n" + out + "[:structural:]";
	}
}
